import Cookies from 'js-cookie'
//本地缓存user的对应的name
const LOCAL_USER_NAME = 'JH_SYSTEM'

//----------------localStorage---------------
export function getLocalUser() {
  return getLocalObject(LOCAL_USER_NAME);
}

export function setLocalUser(userData) {
  return setLocalObject(LOCAL_USER_NAME, userData);
}

export function removeLocalUser() {
  return localStorage.removeItem(LOCAL_USER_NAME);
}

export function getLocalObject(name) {
 return JSON.parse(localStorage.getItem(name))
}

export function setLocalObject(name, obj) {
  return localStorage.setItem(name, JSON.stringify(obj));
}

export function removeLocalObject(name) {
  return localStorage.removeItem(name);
}

//---------------Cookie--------------------
export function getCookieValue(name) {
  return Cookies.get(name)
}

export function setCookie(name, token) {
  return Cookies.set(name, token)
}

export function removeCookie(name) {
  return Cookies.remove(name)
}
